package com.boco.wmworkflow.wfgeneric.action;

import javax.servlet.http.HttpServlet;
import com.boco.wmworkflow.base.WfActionHelper;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import com.boco.transnms.server.bo.base.BoName;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import com.boco.transnms.common.dto.base.IBoActionContext;
import com.boco.wmworkflow.wfgeneric.bo.WfGenericBO;
import com.boco.transnms.common.dto.base.BoActionContext;

public class AttachFileDeleteServlet  extends HttpServlet {
    public void init() throws ServletException {
        System.out.println("in attachFileDeleteServlet .......");
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String attachId;
        String sheetId;
        String attachType;
        try {
            attachId = request.getParameter("attachId");
            String ids[] = attachId.split("\"");
            if(ids.length==2){
                attachId = ids[1];
            }
            sheetId = request.getParameter("sheetId");
            attachType = request.getParameter("attachType");
            BoActionContext dbContext = new BoActionContext();
            getGenericBO().delAttachFile(dbContext, attachId);
//            String url = "/wmworkflow/common/jsp/attachOptSheet.jsp?attachId="+attachId+"&sheetId="+sheetId+"&attachType="+attachType;
//            request.getRequestDispatcher(url).forward(request,response);
            //response.sendRedirect(url);
        } catch (Exception ex) {
            request.setAttribute("errors", ex.getMessage());
        }
    }



    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }



    private WfGenericBO getGenericBO(){
        return new WfGenericBO(BoName.WfGenericBO);
    }
}
